package cn.merryyou.jpa.domain.primarykey;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import java.io.Serializable;

@Getter
@Setter
@NoArgsConstructor
public class CourseUserPK implements Serializable {
    private static final long serialVersionUID = -1788645875633226746L;
    private Integer course;
    private Integer person;

    public boolean equals(Object object) {
        if (this == object)
            return true;
        if (!(object instanceof CourseUserPK))
            return false;
        final CourseUserPK other = (CourseUserPK) object;
        if (this.course != null && other.getCourse() != null) {
            if (course == other.course) {
                if (person != null && other.getPerson() != null && person == other.getPerson()) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return true;
            }
        } else
            return false;
    }

    public int hashCode() {
        return super.hashCode() +
                (course != null ? course.hashCode() : 0) +
                (person != null ? person.hashCode() : 0);
    }
}